import 'package:flutter/material.dart';
import 'package:flutter_staggered_grid_view/flutter_staggered_grid_view.dart';
import 'package:xindong/models/user/xindong_kongjian_user.dart';
import 'package:xindong/routes/userspace/view/xindong_kongjian_info_gift_item.dart';
import 'package:xindong/routes/userspace/view/xindong_kongjian_title_container.dart';

class XinDongKongJianInfoGift extends StatelessWidget {
  final XinDongSpaceUser model;

  const XinDongKongJianInfoGift({super.key, required this.model});

  @override
  Widget build(BuildContext context) {
    const double spacing = 8.0;
    final dataList = model.gift ?? [];
    if (dataList.isEmpty) return const SizedBox();
    return XinDongKongJianTitleContainer(
      title: '收到的礼物',
      children: [
        AlignedGridView.count(
          itemCount: dataList.length,
          padding: const EdgeInsets.only(top: 10, bottom: 10),
          crossAxisCount: 4,
          mainAxisSpacing: spacing,
          crossAxisSpacing: spacing,
          shrinkWrap: true,
          physics: const NeverScrollableScrollPhysics(),
          itemBuilder: (BuildContext context, int index) {
            final model = dataList[index];
            return XinDongKongJianInfoGiftItem(
              model: model,
              onTap: () {},
            );
          },
        ),
      ],
    );
  }
}
